﻿@model IfSoft.OA.Entities.BankBill
           
<script type="text/javascript">
    $(document).ready(function () { $('.date').datepicker({ dateFormat: "dd/mm/yy" }); });
    var i = 0;
    function createDetailUI() {
        i++;
        var addHtml = '<li>日期：<input type="text" id="detailItem-' + i + '" name="detailItem-' + i + '"/>内容：</li>';
        $("#createDetails ul").append(addHtml);
        $("#createDetails li").last().fadeIn("slow");
        $("#btnDeleteDetailUI").show();
    }

    function deleteDetailUI() {

        var list = $("#createDetails li");
        //fileUploads.last().fadeOut("slow");
        list.last().remove();
        if (list.length == 1)
            $("#btnDeleteDetailUI").hide();

    }

    function deleteDetail(id) {
        if (confirm("您确认删除改纪录么？")) {
            $.ajax({
                type: "POST",
                url: "/BankBillController/DeleteDetail/" + id,
                beforeSend: function (XMLHttpRequest) {
                    //ShowLoading();
                },
                success: function (data, textStatus) {
                    $("#detailItem-" + id + "").fadeOut("slow");
                },
                error: function () {
                    alert("删除失败！")
                }
            });
        }
    }
</script>

@if (Model != null && Model.BankBillDetails != null && Model.BankBillDetails.Count > 0)
{
    foreach (var detail in Model.BankBillDetails)
    { 
    <ul class="bankBillDetail" id=@string.Format("{0}-{1}", "bankBillDetail", detail.Id)>
        <li>
            <span>@detail.KeyDate</span> | <span>@detail.Description</span>
            <a onclick="deleteDetail(@detail.Id); return false;">删除</a>
        </li>      
    </ul>
    }
}

<div id="createDetails">
    <ul>
    </ul>
</div>
<button value="Create" onclick="createDetailUI();return false;" >添加内容</button>
<button value="Delete" id="btnDeleteDetailUI"  onclick="deleteDetailUI();return false;" style="display: none">删除内容</button>


